{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from autocoder.common.anything2images import Anything2Images\n",
    "from autocoder.common import AutoCoderArgs\n",
    "import byzerllm\n",
    "from autocoder.utils.rest import HttpDoc\n",
    "import nest_asyncio\n",
    "\n",
    "nest_asyncio.apply()\n",
    "\n",
    "byzerllm.connect_cluster()\n",
    "llm = byzerllm.ByzerLLM()\n",
    "llm.setup_default_model_name(\"deepseek_chat\")\n",
    "llm.setup_template(\"deepseek_chat\",\"auto\")\n",
    "\n",
    "model = \"qianwen_vl_max_chat\"\n",
    "model = \"gpt4o_chat\"\n",
    "vl_model = byzerllm.ByzerLLM()\n",
    "vl_model.setup_default_model_name(model)\n",
    "vl_model.setup_template(model,\"auto\")\n",
    "\n",
    "llm.setup_sub_client(\"vl_model\",vl_model)\n",
    "\n",
    "urls=[\"https://github.com/PaddlePaddle/PaddleOCR/blob/main/doc/doc_ch/quickstart.md\"]\n",
    "args = AutoCoderArgs(output=\"/tmp/jack\",single_file=False,urls=urls,urls_use_model=True)\n",
    "http_doc = HttpDoc(args,llm,urls=urls)\n",
    "# http_doc.crawl_urls()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "with open(\"./conversations.json\",\"r\") as f:    \n",
    "    data = json.loads(f.read())    \n",
    "    content = json.loads(data[-1][\"content\"])\n",
    "    html = content[0][\"text\"]\n",
    "    k = http_doc._extract_main_content.with_llm(http_doc.llm).with_response_markers([\"<MARKER>\", \"</MARKER>\"]).run(url=\"xxx\",html=html)\n",
    "    print(k)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "byzerllm",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
